package com.xnyzc.lhy.nio.feign.fallback.netty;

import com.xnyzc.lhy.common.entity.Qd;
import com.xnyzc.lhy.nio.entity.netty.DriverVehInfo;
import com.xnyzc.lhy.nio.entity.netty.MileageParam;
import com.xnyzc.lhy.nio.entity.netty.TimeParam;
import com.xnyzc.lhy.nio.feign.netty.FeignNettyService;
import com.xnyzc.lhy.order.entity.order.OaCOrder;
import com.xnyzc.lhy.order.entity.system.OaSysBillRules;
import com.xnyzc.lhy.order.entity.user.OaCUser;
import com.xnyzc.lhy.order.entity.user.OaDUser;
import com.xnyzc.lhy.order.entity.user.OaDUserInfo;
import com.xnyzc.lhy.order.entity.vehicle.OaDDriverVehicle;
import com.xnyzc.lhy.order.entity.vehicle.OaSysVehicle;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 服务的降级， 如出现远程调用失败，则会触发该回调
 *
 * @author liuju
 * @since 2019-09-20
 */
@Slf4j
@Service
public class FeignNettyServiceFallback implements FeignNettyService {


    /**
     * netty 获取司机车辆信息
     *
     * @return
     */
    @Override
    public DriverVehInfo getDDriverVehicleInfo(String vehicleId) {
        log.info("netty 获取司机车辆信息失败");
        return null;
    }

    /**
     * netty 获取车辆信息
     *
     * @param vehicleId
     * @return
     */
    @Override
    public OaSysVehicle getSysVehicleInfo(Long vehicleId) {
        OaSysVehicle oaSysVehicle = new OaSysVehicle();
        log.info("netty 获取车辆信息失败");
        return oaSysVehicle;
    }


    /**
     * netty 获取里程费
     *
     * @return
     */
    @Override
    public BigDecimal getMileageFee(MileageParam param) {
        BigDecimal mileageFee = new BigDecimal("0.0");
        log.info("netty 获取里程费失败");
        return null;
    }

    @Override
    public OaCOrder getMileageFeeByOrder(OaCOrder oaCOrder) {
        log.info("获取里程费失败!");
        return oaCOrder;
    }

    @Override
    public OaCOrder getDistanceFeeByOrder(OaCOrder oaCOrder) {
        log.info("获取远途费失败!");
        return oaCOrder;
    }

    /**
     * netty 获取时长费
     *
     * @return
     */
    @Override
    public BigDecimal getTimeFee(TimeParam param) {
        BigDecimal timeFee = new BigDecimal("0.0");
        log.info("netty 获取时长费失败");
        return new BigDecimal(0);
    }

    @Override
    public OaCOrder getTimeFeeByIdOrder(OaCOrder oaCOrder) {
        log.info("获取时长费失败!");
        return oaCOrder;
    }


    /**
     * netty 获取总费用
     *
     * @param totalFee
     * @param baseFee
     * @param userType
     * @param drawRatio
     * @return
     */
    @Override
    public BigDecimal getTotalFee(BigDecimal totalFee, BigDecimal baseFee, Integer userType, BigDecimal drawRatio) {
        BigDecimal totalFees = new BigDecimal("0.0");
        log.info("netty 获取总费用失败");
        return new BigDecimal(0);
    }

    /**
     * netty 获取计费规则费用
     *
     * @param rulesId
     * @param tag
     * @return
     */
    @Override
    public OaSysBillRules getBillRulesStartFee(String rulesId, String tag) {
        OaSysBillRules oaSysBillRules = new OaSysBillRules();
        log.info("netty 获取计费规则费用失败");
        return oaSysBillRules;
    }

    /**
     * netty 判断是否评价过
     *
     * @param userId
     * @param type
     * @param orderNo
     * @return
     */
    @Override
    public Integer isEvaluation(Long userId, Integer type, String orderNo) {
        Integer isEvaluation = 0;
        log.info("netty 获取是否评价过接口调用失败");
        return isEvaluation;
    }

    /**
     * netty 获取历史轨迹
     *
     * @param orderNo
     * @return
     */
    @Override
    public List<Qd> getHistroyGpsList(String orderNo) {
        List<Qd> gpsList = new ArrayList<>();
        log.info("netty 获取历史轨迹失败");
        return gpsList;
    }

    /**
     * 获取订单信息
     *
     * @param orderNo
     * @return
     */
    @Override
    public OaCOrder getOrderInfo(String orderNo) {
        OaCOrder oaCOrder = new OaCOrder();
        log.info("netty 获取订单信息失败");
        return oaCOrder;
    }

    /**
     * 获取用户信息
     *
     * @param userId
     * @return
     */
    @Override
    public OaCUser getUserInfo(Long userId) {
        OaCUser oaCUser = new OaCUser();
        log.info("netty 获取用户信息失败");
        return oaCUser;
    }

    /**
     * 乘客端获取当前等待人数等信息
     *
     * @param lng
     * @param lat
     * @return
     */
    @Override
    public Integer getNearbyVehicles(String lng, String lat) {
        Integer nearbyVehicles = 0;
        log.info("netty 乘客端获取当前等待人数等信息失败");
        return nearbyVehicles;
    }

    /**
     * 获取司机用户信息
     *
     * @param driverId
     * @return
     */
    @Override
    public OaDUser getOaDUser(Long driverId) {
        OaDUser oaDUser = new OaDUser();
        log.info("netty 获取司机用户信息");
        return oaDUser;
    }

    /**
     * 获取司机用户信息详情
     *
     * @param driverId
     * @return
     */
    @Override
    public OaDUserInfo getOaDUserInfo(Long driverId) {
        OaDUserInfo userInfo = new OaDUserInfo();
        log.info("netty 获取司机用户信息详情失败");
        return userInfo;
    }

    /**
     * 获取司机车辆信息
     *
     * @param driverId
     * @param isUse
     * @return
     */
    @Override
    public OaDDriverVehicle getOaDDriverVehicleInfo(Long driverId, Integer isUse) {
        OaDDriverVehicle oaDDriverVehicle = new OaDDriverVehicle();
        log.info("netty 获取司机车辆信息失败");
        return oaDDriverVehicle;
    }

    /**
     * 获取远途费
     *
     * @param param
     * @return
     */
    @Override
    public BigDecimal getDistanceFee(MileageParam param) {
        log.error("未获取到远途费");
        return new BigDecimal(0);
    }

    /**
     * 获取抽佣后费用
     *
     * @param totalBillFee
     * @param rulesId
     * @return
     */
    @Override
    public BigDecimal getDrawFee(BigDecimal totalBillFee, String rulesId) {
        log.error("未获取到抽佣后费用");
        return new BigDecimal(0);
    }


}
